import org.grails.plugins.lookups.*
// 班级
class Classes {
    String level //等级  （小学、初中、高中）
    int grade // 年级 (一年级....)
    int team // 班
    Teacher master  //班主任
    static hasMany = [ student : Student , teacherCourseClasses : TeacherCourseClasses ]
    Date buildTime // 班级建立时间
    Boolean enable = true //班级是否可用，默认可用。true为可用
    School school

    static mapping = {
       table 'xedu_classes'
       buildTime column:'build_time'
       master column:'classes_master'
       grade column:'classes_grade'
       level column:'classes_level'

       student sort : 'name' , order : 'asc'
    }

    static constraints = {
        level()
        grade(nullable:true)
        team(nullable:true)
        master(nullable:false)
        buildTime()
        school(nullable:true)

    }

    String toString() {
        "${level}${Lookup.valueFor('grades', grade)}${Lookup.valueFor('teams', team)}"
    } 
            
}
